﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
namespace TuongLai_Schools
{
    public class cls_DM_Chucvulop
    {
        public DataTable GetAll_Chucvulop()
        {
            DbAccess db = new DbAccess();
            db.CreateNewSqlCommand_Text();
            DataTable dataTable = db.ExecuteDataTable("Select ChucVuLopID,TenChucVuLop,GhiChu,isChangeable from DM_ChucVuLop");
            return dataTable;
        }
        public bool Insert(clsDM_Chucvulop obj)
        {
            try
            {
                DbAccess db = new DbAccess();
                db.CreateNewSqlCommand_Text();
                db.AddParameter("@ChucVuLopID", obj.ChucVuLopID);
                db.AddParameter("@TenChucVuLop", obj.TenChucVuLop);
                db.AddParameter("@GhiChu", obj.GhiChu);
                db.AddParameter("@isChangeable", obj.isChangeable);
                db.ExecuteNonQuery("insert into DM_ChucVuLop(TenChucVuLop,GhiChu,isChangeable) values(N'" + obj.TenChucVuLop + "',N'" + obj.GhiChu + "','" + obj.isChangeable + "')");
                return true;
            }
            catch
            {
                return false;
            }
        }
        public bool update(clsDM_Chucvulop obj)
        {
            try
            {
                DbAccess db = new DbAccess();
                db.CreateNewSqlCommand_Text();
                db.AddParameter("@ChucVuLopID", obj.ChucVuLopID);
                db.AddParameter("@TenChucVuLop", obj.TenChucVuLop);
                db.AddParameter("@GhiChu", obj.GhiChu);
                db.AddParameter("@isChangeable", obj.isChangeable);
                db.ExecuteNonQuery("update DM_ChucVuLop set TenChucVuLop=N'" + obj.TenChucVuLop + "',GhiChu=N'" + obj.GhiChu + "',isChangeable='" + obj.isChangeable + "' where ChucVuLopID='" + obj.ChucVuLopID + "'");
                return true;
            }
            catch
            {
                return false;
            }
        }
        public bool delete(int Chucvulopid)
        {
            try
            {
                DbAccess db = new DbAccess();
                db.CreateNewSqlCommand_Text();
                db.AddParameter("@ChucVuLopID", Chucvulopid);
                db.ExecuteNonQuery("delete DM_ChucVuLop where ChucVuLopID='" + Chucvulopid + "'");
                return true;
            }
            catch
            {
                return false;
            }
        }

    }
}
